<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>注册</title>
    <link rel="stylesheet" href="css/base.css" />
    <link rel="stylesheet" href="css/iconfont.css" />
    <link rel="stylesheet" href="css/login.css" />
    <link rel="stylesheet" href="css/all.css" />
</head>
<body>
<div>
    <div>
         <span href="javascript:;" onclick="go()">
        <i class="iconfont icon-iconfontjiantou1"></i></span>
    </div>
    <div class="logo">
        <img src="img/LOGO.png" alt="">
    </div>
    <div class="cell">
        <i>+86</i>
        <input type="text" placeholder="请输入手机号" class="resetUpwd-input" id="phone"/>
    </div>
    <div class="cell">
        <input type="text" placeholder="请输入验证码" class="resetUpwd-inputs" id="loginCode"/>
        <input type="button " value="获取验证码" class="verity">
    </div>
    <div class="cell">
        <input type="text" placeholder="请输入密码" class="resetUpwd-input" id="loginPassword"/>
    </div>
   
    <div onclick="location.href='./register.html'">
    <div class="consent">
        <p>已有账号去登录</p>
    </div>
    </div>
    <button class="resetUpwd" type="button">注册</button>   
    <!--type="button" value="" class="resetUpwd" />-->
    <div class="cells">
        <i></i>
        <span>我已同意蒲公英计划相关</span><span>注册服务条款</span>
    </div>
</div>
<script src="js/x_rem.js"></script>
<script src="js/jquery.js"></script>
<script src="js/all.js"></script>
<script>
	//点击验证码
	$(".verity").click(function(){
		//保存this
		var that = $(this);
		//判断手机号是否符合格式
		if(vali($("#phone"), /^1[0-9]{10}$/, "请输入正确的手机号")){
			//传入ajax的参数
			var data={
				mobilePhone : $("#phone").val()
			}
			//调用成功后执行
			var callback=()=>{
				console.log("xx");
				count(that);
			}
			
			//调用ajax 
			Hajax("post","/user/doCode",data,callback);
			
 
		}

 
	})
	
	
	//点击注册
	$(".resetUpwd").click(()=>{
		if(!vali($("#phone"), /^1[0-9]{10}$/, "请输入正确的手机号")){
			
		}else if($("#loginCode").val() == ""){
			popup("验证码不能为空");
		}else if(!vali($("#loginPassword"),/^[a-zA-Z0-9_]{6}$/,"请输入6位字母或数字")){
			
		}else{
			//要穿的参数
			var data={
				userName : $("#phone").val(),
				password : $("#loginPassword").val(),
				code : $("#loginCode").val()
			}
			
			//调用成功后执行
			var succeed=()=>{
				popup("注册成功,请登录!!!");
				
				//定时器两秒后调用
				setInterval(()=>{
					location.href = "register.html";
				},2000)
				
			}
			
			//调用ajax
			Hajax("post","/user/register",data,succeed);
			 
			 
		}
		
		
		
		
	})
	
	
	
 
	
	
</script>
</body>
</html>